function  loadDeals(deal_url){
	//var global_deal_url = encodeURI(deal_url);
	var global_deal_url = deal_url;
	$("#deallist_div").load(global_deal_url);
	
}



function  setSearchKey(key){
	document.getElementById("key").value = key;
}

function addCurrent(id){
	$("#header_index_0").removeClass('header_current_a');
	$("#header_index_1").removeClass('header_current_a');
	$("#header_index_2").removeClass('header_current_a');
	$("#header_index_3").removeClass('header_current_a');
	$("#header_index_4").removeClass('header_current_a');
	$("#"+id).addClass('header_current_a');
}

function  createPage(id,total, pageth){

	$("#"+id).paging(total, { // make 1337 elements navigatable
        format: '[< ncnnn! >]', // define how the navigation should look like
        perpage: 15, // show 10 elements per page
        lapping: 0, // don't overlap pages for the moment
       page: pageth, // start at page, can also be "null" or negative
       blockwide: 15,
       //onSelect: testtest, // callback is called when user selects a page
        onFormat: function (type) {
            switch (type) {
            case 'block': // n and c
            		if (!this.active)
            			return '';
            		else if (this.value != this.page)
            			return '<em><a href="#' + this.value + '">&nbsp' + this.value + '&nbsp</a></em>';
            		return '<span class="current" style="color:black;font-weight:bold;font-size:18px;">&nbsp' + this.value + '&nbsp</span>';
            case 'next': // >
                    return '<a title=\'下一页\'>&nbsp&gt;&nbsp</a>';
            case 'prev': // <
                    return '<a title=\'上一页\'>&nbsp&lt;&nbsp</a>';
            case 'first': // [
                    return '<a>首页</a>';
            case 'last': // ]
                    return '<a>末页</a>';
            }
    },  // callback is called once for every "format" element
    
    onSelect: function (page) {
    	if(page != pageth){
    	loadDeals(getDealUrl()+'&page=' + page);
    	}
}
    });
	
	//alert(id);
}

function getDealUrl(){
	var url = "/tuan/getDeals";
	var cityName=encodeURIComponent(document.getElementById("cityName").value);	
	
	//console.log("cityName:"+cityName);
	var cateId=document.getElementById("cateId").value;	
	var key=encodeURIComponent(document.getElementById("key").value);	
	return url + "?cityName="+cityName+"&cateId="+cateId+"&key="+key;
}



